package cn.school.thoughtworks.section3;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class PracticeD {
    Map<String,Integer> createUpdatedCollection(List<String> collectionA, Map<String,List<String>> object) {
        //实现练习要求，并改写该行代码。
        Map<String,Integer> collection3=new HashMap();
        for(int i=0;i<collectionA.size();i++){
            if(collectionA.get(i).length()>1){
                String [] strings=collectionA.get(i).split("-");
                collection3.put(strings[0],Integer.parseInt(strings[strings.length-1]));
            }else{
                Integer num=  collection3.get(collectionA.get(i));
                if(num!=null){
                    collection3.put(collectionA.get(i),num+1);
                }else {
                    collection3.put(collectionA.get(i),1);
                }
            }
        }
        for (String s:collection3.keySet()){
            for(String x:object.get("value")){
                if (s.equals(x)){
                    Integer i = collection3.get(s);
                    int i1 = i / 3;
                    collection3.put(s,i-i1);
                }
                collection3.put(s,collection3.get(s));

            }

        }
        return collection3;
    }
}
